import ui_utils._


object install_scim_input_method {
  val scim_opts = new OPT_LIST()

  def MakeOptions () {
    var optid = 0

    var opt_scim = new OPTION(optid, "Install SCIM")
    optid = optid + 1
    opt_scim.AddCommand("sudo apt-get update")
    opt_scim.AddCommand("sudo apt-get install scim")
    scim_opts.AddOption(opt_scim)

    var opt_chewing = new OPTION(optid, "Install Tranditional Chinese Input (chewing)")
    optid = optid + 1
    opt_chewing.AddCommand("sudo apt-get install scim-chewing")
    scim_opts.AddOption(opt_chewing)

    var opt_pinyin = new OPTION(optid, "Install Simplified Chinese Input (pinyin)")
    optid = optid + 1
    opt_pinyin.AddCommand("sudo apt-get install scim-pinyin")
    scim_opts.AddOption(opt_pinyin)
  }

  def main (args : Array[String]) {
    // initialize option menu
    MakeOptions()

    // acquire the selections
    // val uiutils = new UI_UTILS();
    var selections = UI_UTILS.DisplayOptions(scim_opts, UI_UTILS.GetIntsFromConsole);
    selections = selections.sortBy(x => x)

    // run the selected options (corresponding commands) 
    for (i <- 0 until selections.length) {
      try {
	scim_opts.RunOption(selections(i))
      } catch {
	case _ : NoSuchOptionException => println("Unavailable Option ["+selections(i).toString+"]")
      }
    }
  }
}
